#include "aliyun_iot_platform_random.h"

int aliyun_iot_gen_random(unsigned char *random, unsigned int len)
{
    FILE *file;
    unsigned int read_len;

    file = fopen("/dev/urandom", "rb");
    if (NULL == file)
    {
        return -1;
    }

    read_len = fread(random, 1, len, file);
    if (read_len != len)
    {
        fclose(file);
        return -1;
    }

    fclose(file);

    return 0;
}

